<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>外边距塌陷问题</title>
    <style>
        .father {
            width: 300px;
            height: 300px;
            background-color: aqua;

            /* overflow: hidden; */
            border-top: 1px solid #ddd;
        }

        .son {
            width: 100px;
            height: 100px;
            background-color: red;
            margin-top: 50px;
        }
    </style>
</head>

<body>
    <!-- 
        外边距塌陷问题
        原因:给子盒子设置了margin-top属性,导致父盒子跟着移动
        解决办法:
        1.子盒子不用margin-top,给父盒子用padding
        2.给父盒子用overflow:hidden属性
        3.给父盒子用border-top属性
     -->
    <div class="father">
        <div class="son"></div>
    </div>
</body>

</html>